package thread;

public class Demo11 {
    public static void main(String[] args) throws InterruptedException {
        Thread t=new Thread(()-> {
            for (int i = 0; i < 10; i++) {
                System.out.println("Hello thread");
                try {
                    Thread.sleep(1000);
                }catch (InterruptedException e){
                    throw new RuntimeException(e);
                }
            }
            System.out.println("t 线程结束");
        });
        //t.setDaemon(true);
        t.start();
        //Thread.sleep(2000);
        //等待线程
        t.join(5000);//等待最大时间 5秒后不等了
        System.out.println("main 线程结束");
    }
}
